package grailsworkshop2012_1_f

class Trip {
    String name
    String city
    Date startDate
    Date endDate
    
    String purpose
    String notes
    static belongsto = [owner : User] 
    //Se crea relación uno a uno con Budget
    static belongsTo = Budget
    
    static constraints = {
        name blank: false, size: 3..15, unique: true
        city blank: false
        startDate blank: false, min: new Date().previous()
        endDate(validator: { val, obj -> val >= obj.startDate })
        purpose blank: false, inList:["Pleasure", "Education", "Business", "Scientific", "Political"]
        notes blank: false
    }
    
    String toString() {
        "${name}"
    }   
}

